import {http,api} from '../../http'
import {put,call,takeLatest} from 'redux-saga/effects'


const requestAddGoodsToCart=async(payload)=>{
    sessionStorage.setItem('addCar',false);
    const result =await http.post(api.ADD_GOODS_TO_CART_API, payload)
    if(result.code===0){
        sessionStorage.setItem('addCar',true);
    }
}

function*fetchAddGoodsToCart({payload}){
    yield call(requestAddGoodsToCart,payload);
}

function *addGoodsToCartEffect(){
    yield takeLatest('user/add_goods_to_car',fetchAddGoodsToCart)
}
 
export default [addGoodsToCartEffect]